import React from 'react';
import './index.less';
import {connect} from "dva";
import Curd from "components/Curd";
import createColumns from "./columns";


@connect(({refund}) => ({refund}))
export default class extends Curd {

  static defaultProps = {
    align: 'center',
    searchType: 'inline',
    searchCols: {span: 8},
    showToolbar: false,
  }

  getNamespace() {
    return 'refund';
  }

  getTableColumns() {
    return createColumns(this);
  }

  componentDidMount() {

    !!this.props.onRef && this.props.onRef(this);
    this.refresh();
  }

  componentDidUpdate(prevProps, prevState, snapshot) {

    if(prevProps.outTradeNo != this.props.outTradeNo){

      this.refresh();
    }

  }

  refresh = () => {
    const {outTradeNo} = this.props;
    console.log("outTradeNo", outTradeNo);

    if (!!outTradeNo){
      this.getPageInfo({pageNum: 1, pageSize: 10, filters: {outTradeNo}});
    }
  }

}
